<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>确认收货人资料和送货方式 - 安阳师范网购系统！</title>
<link type="text/css" href="<%=basePath%>/mallstyle/css/header.css"
	rel="stylesheet" />
<link type="text/css" href="<%=basePath%>/mallstyle/css/main.css"
	rel="stylesheet" />
<link type="text/css" href="<%=basePath%>/mallstyle/css/footer.css"
	rel="stylesheet" />
<link type="text/css" href="<%=basePath%>/mallstyle/css/qq.css"
	rel="stylesheet" />
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/index.js"></script>
<script type="text/javascript"
	src="<%=basePath%>/mallstyle/js/jquery.js" charset="utf-8"></script>
<script type="text/javascript"
	src="<%=basePath%>/mallstyle/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/cart.js"
	charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/main.js"
	charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/qq.js"
	charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/kissy.js"></script>
<script type="text/javascript"
	src="<%=basePath%>/mallstyle/js/switchable-pkg.js"></script>
<!--[if lte IE 6]>
<script type="text/javascript" language="Javascript" src="http://www.999000.cn/themes/mall/default/styles/default/<%=basePath%>/mallstyle/js/hoverForIE6.js"></script>
<![endif]-->

<!--<editmode></editmode>-->

</head>
<body>
	<%@include file="../../../nav.jsp"%>
     <%@include file="../../../header.jsp"%>
	<div id="main" class="w-full">
		<div id="page-order" class="w">
			<div class="step step2 mt10 clearfix">
				<span class="fs14 strong f60">1.查看购物车</span> 
				<span class="fs14 strong fff">2.确认订单信息</span> 
				<span class="fs14 strong">3.付款</span>
				<span class="fs14 strong">4.确认收货</span> 
				<span class="fs14 strong">5.评价</span>
			</div>
			<div class="order-form">
				<form method="post" id="order_form">
					<script type="text/javascript"
						src="http://www.999000.cn/includes/libraries/javascript/mlselection.js"
						charset="utf-8"></script>
					<script type="text/javascript"
						src="http://www.999000.cn/includes/libraries/javascript/jquery.plugins/jquery.validate.js"
						charset="utf-8"></script>
					<script type="text/javascript"
						src="http://www.999000.cn/includes/libraries/javascript/dialog/dialog.js"
						id="dialog_js" charset="utf-8"></script>
					<script type="text/javascript"
						src="http://www.999000.cn/includes/libraries/javascript/jquery.ui/jquery.ui.js"
						id="dialog_js" charset="utf-8"></script>
					<script type="text/javascript">
						var defaultprovince = "宁夏";
						var can_home_payfee = "";
						var home_payfee_array = new Array();
						home_payfee_array = can_home_payfee.split(",");
						var shippings = {
							"19" : {
								"shipping_id" : "19",
								"store_id" : "2",
								"shipping_name" : "\u5feb\u9012",
								"shipping_desc" : "",
								"first_price" : "8.00",
								"step_price" : "1.00",
								"cod_regions" : "a:0:{}",
								"enabled" : "1",
								"sort_order" : "255"
							}
						};
						var addresses = [];
						var goods_amount = 67.6;
						var goods_quantity = 1;
						function in_array(a, v) {
							var i;
							for (i = 0; i < a.length; i++) {
								if (v === a[i]) {
									return i;
								}
							}
							return -1;
						}

						function payforprovince(province) {
							defaultprovince = province;
							if (in_array(home_payfee_array, province) == -1
									&& province != "") {
								if ($('input[name=payment_id]').eq(0).attr(
										"checked")) {
									//$('input[name=payment_id]').eq(0).attr("checked","true");
								}
								$('ul[payment_id]').eq(1)
										.css("display", "none");
							} else {
								$('ul[payment_id]').eq(1).css("display",
										"block");
								//$('input[name=payment_id]').eq(0).attr("checked","true");
							}
							//$('input[name=payment_id]').eq(0).attr("checked","true");
						}

						$(function() {
							regionInit("region");
							//payforprovince(defaultprovince);
							$('#order_form')
									.validate(
											{
												invalidHandler : function(e,
														validator) {
													var err_count = validator
															.numberOfInvalids();
													var msg_tpl = '对不起，你的订单收货地址信息不全，请修改后再提交！';
													var d = DialogManager
															.create('show_error');
													d.setWidth(400);
													d.setTitle(lang.error);
													d.setContents('message', {
														type : 'warning',
														text : $.format(
																msg_tpl,
																err_count)
													});
													d.show('center');
												},
												errorPlacement : function(
														error, element) {
													var _message_box = $(
															element)
															.parent()
															.find(
																	'.field_message');
													_message_box.find(
															'.field_notice')
															.hide();
													_message_box.append(error);
												},
												success : function(label) {
													label.addClass(
															'validate_right')
															.text('OK!');
												},
												rules : {
													consignee : {
														required : true
													},
													region_id : {
														required : true,
														min : 1
													},
													address : {
														required : true
													},
													phone_mob : {
														required : check_phone,
														minlength : 6,
														digits : true
													}
												},
												messages : {
													consignee : {
														required : '请如实填写您的收货人姓名'
													},
													region_id : {
														required : '请选择所在地区',
														min : '请选择所在地区'
													},
													address : {
														required : '请如实填写收货人详细地址'
													},
													phone_mob : {
														required : '固定电话和手机号码至少填一个',
														minlength : '错误的手机号码,只能是数字,并且不能少于6位',
														digits : '错误的手机号码,只能是数字,并且不能少于6位'
													}
												}
											});

							$('ul[shipping_id]')
									.each(
											function() {
												var _shipping_fee = get_shipping_fee($(
														this).attr(
														'shipping_id'));
												$(this)
														.find(
																'[ectype="shipping_fee"]')
														.html(
																price_format(_shipping_fee));
											})
									.click(
											function() {
												$(this)
														.find(
																'input[name="shipping_id"]')
														.attr('checked', true);
												$('.shipping_item')
														.removeClass('selected');
												$(this).addClass('selected');
												set_order_amount($(this).attr(
														'shipping_id'));
											});

							//select first
							$($('ul[shipping_id]')[0]).click();
						});
						function set_order_amount(shipping_id) {
							var _shipping_fee = get_shipping_fee(shipping_id);
							var _amount = goods_amount + _shipping_fee;
							//$('#order_amount').html(price_format(_amount));
							$('#order_amount').html(price_format(_amount));
						}
						function get_shipping_fee(shipping_id) {
							var shipping_data = shippings[shipping_id];
							var first_price = Number(shipping_data['first_price']);
							var step_price = Number(shipping_data['step_price']);
							return first_price + (goods_quantity - 1)
									* step_price;
						}
						function check_phone() {
							return ($('#phone_tel').val() == '' && $(
									'#phone_mob').val() == '');
						}
						function hide_error(province) {
							change_post_fee(province)
							$('#region').find('.error').hide();
						}

						/*change post-fee*/
						function change_post_fee(province) {
							//payforprovince(province)
							var url = SITE_URL
									+ '/index.php?app=order&act=area&province='
									+ encodeURI(province);
							$
									.getJSON(
											url,
											{
												'store_id' : 2
											},
											function(data) {
												if (data.done) {
													var postfee = 0;
													var onefee = 0;
													var allfee = 0;
													var curid = $(
															"input[name='shipping_id']:checked")
															.val();
													var sid;
													//alert(onefee);
													sid = 19;
													onefee = parseFloat(data.retval.shipping_id_19);
													document
															.getElementById("shipping_pay19").value = onefee;
													$('#shipping_fee19')
															.html(
																	price_format(onefee));
													if (curid == sid) {
														allfee = goods_amount
																+ onefee;
														$('#order_amount')
																.html(allfee);
													}
												} else {
													alert(data.msg);
												}
											});
						}
					</script>
					<script type="text/javascript">
						//<![CDATA[
						$(function() {
							//$("input[name='address_options']").click(set_address);
							$('.address_item')
									.click(
											function() {
												$(this)
														.find(
																"input[name='address_options']")
														.attr('checked', true);
												$('.address_item').removeClass(
														'selected_address');
												$(this).addClass(
														'selected_address');
												set_address();
											});
							//init
							set_address();
						});
						function set_address() {
							var addr_id = $(
									"input[name='address_options']:checked")
									.val();
							if (addr_id == 0) {
								$('#consignee').val("");
								$('#region_name').val("");
								$('#region_id').val("");
								$('#region select').show();
								$("#edit_region_button").hide();
								$('#region_name_span').hide();
								$('#address').val("");
								$('#phone_mob').val("");

								$('#address_form').show();
							} else {
								$('#address_form').hide();
								fill_address_form(addr_id);
							}
						}
						function fill_address_form(addr_id) {
							var addr_data = addresses[addr_id];
							for (k in addr_data) {
								switch (k) {
								case 'consignee':
								case 'address':
								case 'email':
								case 'phone_mob':
								case 'region_id':
									$("input[name='" + k + "']").val(
											addr_data[k]);
									break;
								case 'region_name':
									$("input[name='" + k + "']").val(
											addr_data[k]);
									$('#region select').hide();
									$('#region_name_span').text(addr_data[k])
											.show();
									$("#edit_region_button").show();
									break;
								}
							}
						}

						//]]>
					</script>
					<div id="select-address" class="w mt20">
						<div class="title w mb10">
							<b class="fs14">收货人地址</b> <a href="index.php?app=my_address"
								target="_blank">[管理收货地址]</a>
						</div>
						<div class="f66 w newaddress address_item">
							<input class="mb5" type="radio" name="address_options"
								id="use_new_address" value="0" checked="true" /> 使用新的收货地址
						</div>
						<div class="newaddressform w">
							<ul class="fill_in_content mt10" id="address_form">
								<li>收货人姓名：<input type="text" name="consignee"
									id="consignee" /> <span class="field_message explain"><span
										class="field_notice">请填写真实姓名</span></span>
								</li>
								<li class="clearfix">
									<div class="float-left">所在地区：</div>
									<div id="region" class="float-left">
										<span style="display: none;" id="region_name_span"></span> <input
											id="edit_region_button" type="button" class="edit_region"
											value="编辑" style="display: none;" /> <select
											onchange="hide_error(this.options[this.selectedIndex].text);">
											<option value="0">请选择...</option>
											<option value="3">北京</option>
											<option value="22">天津</option>
											<option value="41">上海</option>
											<option value="61">重庆</option>
											<option value="104">河北</option>
											<option value="116">山西</option>
											<option value="128">辽宁</option>
											<option value="143">吉林</option>
											<option value="153">黑龙江</option>
											<option value="167">内蒙古</option>
											<option value="180">江苏</option>
											<option value="194">浙江</option>
											<option value="206">安徽</option>
											<option value="224">福建</option>
											<option value="234">江西</option>
											<option value="246">山东</option>
											<option value="264">河南</option>
											<option value="283">湖北</option>
											<option value="301">湖南</option>
											<option value="317">广东</option>
											<option value="339">海南</option>
											<option value="342">广西</option>
											<option value="357">四川</option>
											<option value="379">贵州</option>
											<option value="389">云南</option>
											<option value="406">西藏</option>
											<option value="414">陕西</option>
											<option value="425">甘肃</option>
											<option value="440">青海</option>
											<option value="449">宁夏</option>
											<option value="455">新疆</option>
											<option value="474">香港</option>
											<option value="475">澳门</option>
											<option value="476">台湾</option>
										</select> <input type="hidden" class="mls_id" name="region_id"
											id="region_id" /> <input type="hidden" name="region_name"
											class="mls_names" id="region_name" /> <span
											class="field_message explain"><span
											class="field_notice">请选择地区</span></span>
									</div>
								</li>
								<li>详细地址：<input type="text" name="address" id="address" />
									<span class="field_message explain"><span
										class="field_notice">请填写真实地址，不需要重复填写所在地区</span></span>
								</li>
								<li>手机号码：<input type="text" id="phone_mob" name="phone_mob" />
									<span class="field_message explain"><span
										class="field_notice">手机和固定电话至少填一项</span></span>
								</li>
								<li><input style="border: 0;" type="checkbox" value="1"
									id="save_address" name="save_address"><span
									class="explain f66">自动保存收货地址(选择后该地址将会保存到您的收货地址列表)</span></li>
							</ul>
						</div>
					</div>
					<div id="select-shipping" class="mt10">
						<div class="title fs14 strong mb10">选择配送方式</div>
						<div class="content f66">
							<ul class="shipping_item" shipping_id="19">
								<li><input class="mb5" type="radio" name="shipping_id"
									value="19" /> <input name="shipping_pay" id="shipping_pay19"
									type="hidden" value="8" /> 快递 配送费用：<span class="money"
									ectype="shipping_fee" id="shipping_fee19">&yen; 8</span></li>
							</ul>
						</div>
					</div>
					<c:if test="${not empty orderformList }">
						<c:forEach items="${orderformList }" var="orderformList">

							<div class="cartbox w mt20 mb10">
								<div class="title clearfix mb10">
									<span class="col-desc">商家商品</span><span>单价</span> <span>数量</span>
									<span>小计</span> <span>操作</span>
								</div>
								<div class="content">
									<div class="store-each">
										<div class="store-name pb10">
											商家：<a href="index.php?app=store&amp;id=2">安阳师范旗舰店</a>
										</div>
										<c:forEach items="${orderformList.orderdetail }"
											var="orderdetail">
											<dl class="goods-each clearfix">
												<dd class="pic">
													<a class="block" href="index.php?app=goods&amp;id=6568"
														target="_blank"><img
														src="<%=basePath%>/mallstyle/picture/small_201605241016363460.png"
														alt="" width="48" height="48" /></a>
												</dd>
												<dd class="desc">
													<p>
														<a href="#" target="_blank">${orderdetail.gName }</a>
													</p>
													<span class="f66"></span>
												</dd>
												<dd class="price">${orderdetail.odAllprice /orderdetail.odCount}</dd>
												<dd class="quantity">${orderdetail.odCount }</dd>
												<dd class="subtotal fs14 strong">${orderdetail.odAllprice }</dd>
												<dd class="handle">
													<a class="del"
														href="<%=path%>/rest/orderform/deleteOrderformDetail?odid=${orderdetail.odId }">删除</a>
												</dd>
											</dl>
										</c:forEach>
									</div>
								</div>
							</div>



							<script type="text/javascript">
								function postscript_activation(tt) {
									if (!tt.name) {
										tt.value = '';
										tt.name = 'postscript';
										tt.style.height = '50px';
									}
								}
							</script>
							<div id="postscript" class="w clearfix">
								<div class="float-left">给卖家的附言：</div>
								<div class="content float-left">
									<textarea class="f66" style="" id="postscript"
										onclick="postscript_activation(this);">附注：选填，可以告诉卖家您对商品的特殊需求，如颜色、尺码等</textarea>
								</div>
							</div>
						</c:forEach>
					</c:if>
					<script type="text/javascript">
						$(function() {
							/* tyioocom  */
							$('#use_coupon')
									.click(
											function() {
												$(this).parent('p').next()
														.toggle();
												//$(this).hide();

												if ($(this).val() == '使用优惠券') {
													$(this).val('不使用优惠券');
													$("select[name='coupon_sn']")[0].selectedIndex = 0;
												} else {
													$(this).val('使用优惠券')
												}
											});
						});
					</script>
					<div class="w price-promotion mt10 mb10 f60" style="display: none;">
						<p class="mb10 mt10">
							<input id="use_coupon" type="button"
								class="btn-allow-coupon center" value="使用优惠券" />
						</p>
						<p class="allow-coupon border padding10 mb10 hidden clearfix">
							<select name="coupon_sn">
								<option value="">选择您可用的优惠券</option>
							</select> <span class="note">本商城优惠券每次只能使用一张。您可以到 <a
								href='index.php?app=my_coupon'>我的优惠券</a> 登记或者查询具体的优惠券信息：
							</span>
						</p>
					</div>
					<div class="make_sure w mb10" style="margin-top: 10px;">
						<p>
							<a href="index.php?app=cart&amp;store_id=2" class="back"
								style="display: none;">返回购物车</a> <span class="ml20">订单总价：</span>
							<strong id="order_amount_voucher">${sum }</strong>元  <a
								href="<%=path%>/rest/orderform/pay"
								class="btn-step fff center strong fs14 ml20">下单完成并支付</a>
						</p>
					</div>
					<div class="w price-notice mt10 mb10 pt10 f60 pb10">若有价格变动（包括运费），请在点击确认订单后，联系卖家修改。卖家修改后，您可以至订单管理中查看、完成支付。</div>
				</form>
			</div>
		</div>
	</div>
	<div class="clear"></div>

	<%@include file="../../../bottom.jsp"%>

</body>
</html>
